package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookComments;
import com.pgybook.db.entity.domain.BookCommentsEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookCommentsMapper {
    int countByExample(BookCommentsEx example);

    int deleteByExample(BookCommentsEx example);

    @Delete({
            "delete from bookcomments",
            "where COMMENTID = #{commentid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer commentid);

    @Insert({
            "insert into bookcomments (BOOKID, CRTTIME, ",
            "CUSTID, STATUS, CONTENT)",
            "values (#{bookid,jdbcType=BIGINT}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{custid,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, #{content,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "commentid", before = false, resultType = Integer.class)
    int insert(BookComments record);

    int insertSelective(BookComments record);

    List<BookComments> selectByExampleWithBLOBs(BookCommentsEx example);

    List<BookComments> selectByExample(BookCommentsEx example);

    @Select({
            "select",
            "COMMENTID, BOOKID, CRTTIME, CUSTID, STATUS, CONTENT",
            "from bookcomments",
            "where COMMENTID = #{commentid,jdbcType=INTEGER}"
    })
    @ResultMap("ResultMapWithBLOBs")
    BookComments selectByPrimaryKey(Integer commentid);

    int updateByExampleSelective(@Param("record") BookComments record, @Param("example") BookCommentsEx example);

    int updateByExampleWithBLOBs(@Param("record") BookComments record, @Param("example") BookCommentsEx example);

    int updateByExample(@Param("record") BookComments record, @Param("example") BookCommentsEx example);

    int updateByPrimaryKeySelective(BookComments record);

    @Update({
            "update bookcomments",
            "set BOOKID = #{bookid,jdbcType=BIGINT},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "CUSTID = #{custid,jdbcType=BIGINT},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "CONTENT = #{content,jdbcType=LONGVARCHAR}",
            "where COMMENTID = #{commentid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(BookComments record);

    @Update({
            "update bookcomments",
            "set BOOKID = #{bookid,jdbcType=BIGINT},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "CUSTID = #{custid,jdbcType=BIGINT},",
            "STATUS = #{status,jdbcType=INTEGER}",
            "where COMMENTID = #{commentid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(BookComments record);
}
